package com.hzhc.controller.yworder;

import com.hzhc.annotation.SysTemLog;
import com.hzhc.common.BaseController;
import com.hzhc.dto.UserDto;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.CarTeamPlanService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.utils.TokenUtil;
import com.hzhc.vo.CarTeamPlanVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 车辆计划 前端控制器
 * </p>
 *
 * @author 功不唐捐
 * @since 2024-11-06
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/carTeamPlan")
public class CarTeamPlanController extends BaseController {
    private final CarTeamPlanService carTeamPlanService;

    /**
     * 获取计划车牌号
     * @return
     */
    @RequestMapping("/getCarNos")
    @ResponseBody
    public ResultUtil<List<CarTeamPlanVo>> getCarNos(@RequestBody CarTeamPlanVo vo){
        vo.setSearchKey(1);
        List<CarTeamPlanVo> list = carTeamPlanService.getCarNos(vo);
        return ResultUtil.build(list,ResultUtilCodeEnum.SUCCESS);
    }


    /**
     * 修改车辆计划
     */
    @RequestMapping("/updateCarTeamPlan")
    @SysTemLog(operModul = "授权信息-车辆计划修改", operType = "修改", operDesc = "车辆计划修改功能", modular = "PC")
    public ResultUtil<T> updateCarTeamPlan(HttpServletRequest httpServletRequest, @RequestBody CarTeamPlanVo vo) {
        UserDto user= TokenUtil.getUser(httpServletRequest);
        vo.setUserId(user.getId());
        return carTeamPlanService.updateCarTeamPlan(vo);
    }

    /**
     * 车队计划审核
     */
    @RequestMapping("/auditCarTeamPlan")
    @SysTemLog(operModul = "授权信息-车辆计划审核", operType = "审核", operDesc = "车辆计划审核功能", modular = "PC")
    public ResultUtil<T> auditCarTeamPlan(HttpServletRequest httpServletRequest, @RequestBody CarTeamPlanVo vo) {
        UserDto user= TokenUtil.getUser(httpServletRequest);
        vo.setUserId(user.getId());
        return carTeamPlanService.auditCarTeamPlan(vo);
    }
}
